<template>
  <div class="knowledge-manage">
    <el-tabs v-model="activeName">
      <el-tab-pane
        :label="type == 1 ? '思政要素编辑' : '资源设置'"
        name="KnowledgeSetting"
      ></el-tab-pane>
      <el-tab-pane label="辅助素材附件" name="KnowledgeFiles"></el-tab-pane>
    </el-tabs>
    <div
      class="knowledge-wrap"
      ref="knowledge-wrap"
      :style="{ height: wrapHeight + 'px' }"
    >
      <component :is="activeName"></component>
    </div>
  </div>
</template>
<script>
export default {
  components: {
    KnowledgeSetting: () => import('../knowledgeSetting/index.vue'),
    KnowledgeFiles: () => import('../knowledgeFiles/index.vue'),
  },
  data() {
    return {
      activeName: 'KnowledgeSetting',
      type: this.$route.meta.type,
      wrapHeight: 500,
    }
  },
  mounted() {
    setTimeout(() => {
      this.init()
    }, 200)
    window.onresize = () => {
      this.init()
    }
  },
  methods: {
    init() {
      let wHeight = document.body.clientHeight
      if (!this.$refs['knowledge-wrap']) return
      let topDistance = this.$refs['knowledge-wrap'].getBoundingClientRect().top
      this.wrapHeight = wHeight - topDistance - 45
    },
  },
}
</script>
<style scoped>
.knowledge-manage {
  position: relative;
}
.knowledge-manage .knowledge-wrap {
  position: relative;
  /* overflow-y: scroll; */
}
.knowledge-manage .knowledge-wrap::-webkit-scrollbar {
  display: none;
}
</style>